﻿<RadzenTable>
    <RadzenTableHeader>
        <RadzenTableHeaderRow>
            <RadzenTableHeaderCell>Press this key</RadzenTableHeaderCell>
            <RadzenTableHeaderCell>To do this</RadzenTableHeaderCell>
        </RadzenTableHeaderRow>
    </RadzenTableHeader>
    <RadzenTableBody>
        @foreach (var item in Data)
        {
            <RadzenTableRow>
                <RadzenTableCell>
                    @foreach (var key in item.Key.Split(' '))
                    {
                        if (Keys.Contains(key))
                        {
                            <span class="rz-badge rz-badge-primary rz-variant-filled rz-shade-default">@key</span>
                        }
                        else
                        {
                            @($" {key} ")
                        }
                    }
                    </RadzenTableCell>
                <RadzenTableCell>@item.Action</RadzenTableCell>
            </RadzenTableRow>
        }
    </RadzenTableBody>
</RadzenTable>


@code {
    static readonly string[] Keys = [ "Tab", "DownArrow", "UpArrow", "LeftArrow", "RightArrow", "Enter", "Space", "Shift", "Alt", "Esc", "Escape" ];

    [Parameter]
    public IEnumerable<KeyboardShortcut> Data { get; set; }
}